#ifndef _MAP_RECEIVER_H_
#define _MAP_RECEIVER_H_
#include <ros/ros.h>
#include <cv_bridge/cv_bridge.h> 
#include <sensor_msgs/image_encodings.h>
#include <image_transport/image_transport.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace std;
using namespace cv;

class MapReceiver
{
    private:
        ros::NodeHandle nh_;
        image_transport::ImageTransport it_;
        image_transport::Subscriber image_sub_;
        
    public:
        vector<unsigned char> cameraData;
        int cameraWidth{0};
        int cameraHeight{0};
        MapReceiver():it_(nh_)
        {
            image_sub_ = it_.subscribe("xtion_map_server/map", 1, &MapReceiver::OnMapReceived, this); // Topic
            cv::namedWindow("Map");
        }

        ~MapReceiver()
        {
            cv::destroyWindow("Map");
        }

        void OnMapReceived(const sensor_msgs::ImageConstPtr& msg);

        // 地图处理程序
        void MapProcess(cv::Mat &img);
};
#endif